package com.bawei.handler_app;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

/**
 * onCreate->onStart->onResume
 */
public class MainActivity3 extends AppCompatActivity {
    private TextView mTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        mTextView = findViewById(R.id.tv);
//        //子线程更新UI：没问题
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                Log.d("ytx", "子线程更新UI: ");
//                mTextView.setText("hahahahha");
//
//            }
//        }).start();

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d("ytx", "onResume: ");
    }
    //点击事件子线程更新UI：有问题
    public void changgeUi(View view) {
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                Log.d("ytx", "子线程更新UI: ");
//                mTextView.setText("weiweiweiwei");
//
//            }
//        }).start();
    }
}